#ifndef _csIArchive_h_
#define _csIArchive_h_

/********************************************************************
	created:	2009/11/05
	created:	5:11:2009   18:19
	filename: 	e:\csEngine\csCoreLib\src\io\csArchive.h
	file path:	e:\csEngine\csCoreLib\src\io
	file base:	csArchive
	file ext:	h
	author:		dongchengok
	
	purpose:	file archive
*********************************************************************/
#include "csType.h"
#include "csString.h"
#include "csArray.h"
//------------------------------------------------------------------------
class csStream;

//------------------------------------------------------------------------
enum csEArchiveType
{
	csEAT_ZIP = 0,
	csEAT_FILE,
	csEAT_COUNT,
};

//------------------------------------------------------------------------
enum csEStreamAccessType
{
	csESAT_READ = 0,
	csESAT_WRITE,
	csESAT_APPEND,
	csESAT_COUNT,
};

//------------------------------------------------------------------------
class csIArchive
{
public:
	csIArchive();
	virtual ~csIArchive();
	static const csString&		ArchiveTypeToName(csEArchiveType t);
	static csEArchiveType		ArchiveNameToType(const csString& name);

	const csString&				getName() const;
	csEArchiveType				getType() const;
	const csString&				getFullPath() const;

	bool						operator==(const csIArchive& rhs) const;

	virtual csArray<csString>	listArchive() const;
	virtual csArray<csString>	listDictionaryArchive() const;
	virtual csArray<csString>	listFileArchive() const;
	
	virtual csIArchive*			findArchive(const csString& path) const;
	virtual csIArchive*			findOrCreateArchive(const csString& path);

	virtual csStream*			open(const csString& path, csEStreamAccessType type=csESAT_WRITE);
	virtual void				save(const csString& path, csStream& stream);

protected:
	static const csString		ms_archiveTypesName[csEAT_COUNT+1];

	csString					m_name;
	csString					m_fullPath;
};

//------------------------------------------------------------------------
csINLINE const csString&
csIArchive::getName() const
{
	return m_name;
}

//------------------------------------------------------------------------
csINLINE csEArchiveType
csIArchive::getType() const
{
	return csEAT_COUNT;
}

//------------------------------------------------------------------------
csINLINE const csString&
csIArchive::getFullPath() const
{
	return m_fullPath;
}

#endif // _csArchive_h_
